/* UpdateThread.java
 * 
 * Alfred Olschnoegger
 * 23.06.2008
 */

package application.threading;

import application.MainController;

/**
 * TODO description
 *
 * @date 23.06.2008
 * @author Alfred Olschnoegger
 */

public class UpdateThread extends Thread {
	private int m_Interval;
	private MainController m_Controller;
	private boolean m_Running;
	
	/**
	 * 
	 * @param contr		controller to perform the update
	 * @param interval	interval in seconds
	 */
	public UpdateThread(MainController contr, int interval) {
		m_Interval = interval;
		m_Controller = contr;
	}
	
	public void run() {
		m_Running = true;
		
		while(m_Running == true) {
			try {
				System.out.println("m_Interval " + m_Interval);
				m_Controller.updateField();
				sleep(m_Interval * 1000);
			} catch (InterruptedException e) {}
		}
		
	}

	public int getIntervall() {
		return m_Interval;
	}

	/**
	 * 
	 * @param intervall	update interval in seconds
	 */
	public void setInterval(int interval) {
		m_Interval = interval;
	}

	public boolean isRunning() {
		return m_Running;
	}

	public void setRunning(boolean running) {
		m_Running = running;
	}

}


// end of UpdateThread.java
